package team.yidong.fenda.controller;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import team.yidong.fenda.entity.HospitalDepartment;
import team.yidong.fenda.service.GuahaoHistoryService;
import team.yidong.fenda.service.HospitalDepartmentService;

import javax.servlet.http.HttpSession;

/**
 * Created by xuanlong on 2018/3/25.
 */
@Controller
public class GuahaoHistoryController {
    @Autowired
    GuahaoHistoryService guahaoHistoryService;
    @Autowired
    HospitalDepartmentService hospitalDepartmentService;

    @RequestMapping("/guahaoHistory")
    public String guahaoHistory(Model model, HttpSession session) {
        Integer hospitalId = (Integer) session.getAttribute("loginHospitalId");
        model.addAttribute("departments", hospitalDepartmentService.findHospitalDepartment(hospitalId));
        return "guahaoHistory";
    }

    @RequestMapping("/findGuahaoHistoryForSys")
    @ResponseBody
    public JSONArray findGuahaoHistoryForSys(HttpSession session,Integer departmentId, String jiaofeiDate1, String jiaofeiDate2, String yuyueDate1, String yuyueDate2, Integer moneyNum, String guahaoNum, String idCard, String phoneNum) {
        Integer hospitalId = (Integer) session.getAttribute("loginHospitalId");
        return guahaoHistoryService.findGuahaoHistoryForSys(hospitalId, departmentId, jiaofeiDate1, jiaofeiDate2, yuyueDate1, yuyueDate2, moneyNum, guahaoNum, idCard, phoneNum);
    }
}
